/*
2021-8-7
https://ac.nowcoder.com/acm/contest/11258/H
*/
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long ll;
const int N=1e6+5;
int a[N];
int cnt[N];
int n;
int nums[N],num;

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++) 
    {
        scanf("%d",a+i);
        if(!cnt[a[i]]) nums[num++]=a[i];
        cnt[a[i]]++;
    }
    
    sort(a,a+n);
    sort(nums,nums+num);
    ll res=0;
    for(int i=0;i<num;i++)
        for(int j=i;j<num;j++)
        {
            if((ll)nums[i]*nums[j]>1e6) break;
            if((ll)nums[i]*nums[j]<=1e6 && cnt[nums[i]*nums[j]])
            {
                res+=cnt[nums[i]]*cnt[nums[j]]*cnt[nums[i]*nums[j]];
                //cout<<nums[i]<<' '<<nums[j]<<' '<<nums[i]*nums[j]<<' '<<cnt[nums[i]]*cnt[nums[j]]*cnt[nums[i]*nums[j]]<<endl;
                if(i!=j) res+=cnt[nums[i]]*cnt[nums[j]]*cnt[nums[i]*nums[j]];
            }
        }
    cout<<res<<endl;
    return 0;
}

